﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 事件案例1
{

    public delegate void GreetingDelegate(string name);

    public class GreetingManager
    {
        public void GreetPeople(string name, GreetingDelegate MakeGreeting)
        {
            MakeGreeting(name);
        }
    }

    class Program
    {
        private static void EnglishGreeting(string name)
        {
            Console.WriteLine("Good Morning, " + name);
        }

        private static void ChineseGreeting(string name)
        {
            Console.WriteLine("早上好, " + name);
        }

        //static void Main(string[] args)
        //{
        //    GreetingManager gm = new GreetingManager();
        //    gm.GreetPeople("Liker", EnglishGreeting);
        //    gm.GreetPeople("李志中", ChineseGreeting);          
        //    Console.ReadKey();
        //}

        static void Main(string[] args)
        {
            GreetingManager gm = new GreetingManager();
            GreetingDelegate delegate1;
            delegate1 = EnglishGreeting;
            delegate1 += ChineseGreeting;
            gm.GreetPeople("Liker", delegate1);
            Console.ReadKey();
        }
    }
}
